package com.godme.gateway.endpoint;


import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.godme.gateway.sentinel.TestEndpointSentinelResource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestEndpoint {

    @PostMapping("/block")
    @SentinelResource(value = "block",  blockHandler = "block", blockHandlerClass = TestEndpointSentinelResource.class)
    public String block(){
        return "pass";
    }

    @PostMapping("/fallback/{value}")
    @SentinelResource(value = "fallback", fallback = "fallback",fallbackClass = TestEndpointSentinelResource.class)
    public String fallback(@PathVariable("value") Integer value){
        int a = 1/value;
        return "pass";
    }
}
